package com.xbongbong.paas.help.subform.abstracts;

import com.xbongbong.paas.domain.entity.PaasFormDataEntity;
import com.xbongbong.saas.domain.entity.UserAndDepTeamEntity;

import java.util.ArrayList;
import java.util.List;

/**
 * 特殊团队es和数据库转化抽象类
 * @author 魏荣杰
 * @date 2020/8/24 15:41
 * @since
 * @version
 */
public abstract class AbstractUserAndDepTeamTransferSubForm extends AbstractTransferSubForm {


    public List<PaasFormDataEntity> transferTeamToFormDataList(List<? extends UserAndDepTeamEntity> userAndDepTeamEntities) {
        List<PaasFormDataEntity> paasFormDataEntities = new ArrayList<>();
        for (UserAndDepTeamEntity userAndDepTeamEntity : userAndDepTeamEntities) {
            PaasFormDataEntity paasFormDataEntity = transferTeamToFormData(userAndDepTeamEntity);
            paasFormDataEntities.add(paasFormDataEntity);
        }

        return paasFormDataEntities;
    }

    public abstract PaasFormDataEntity transferTeamToFormData(UserAndDepTeamEntity userAndDepTeamEntity);

    public List<UserAndDepTeamEntity> transferFormDataToTeamList(List<PaasFormDataEntity> paasFormDataEntities) {
        List<UserAndDepTeamEntity> userAndDepTeamEntities = new ArrayList<>();
        for (PaasFormDataEntity paasFormDataEntity : paasFormDataEntities) {
            UserAndDepTeamEntity userAndDepTeamEntity = transferFormDataToTeam(paasFormDataEntity);
            userAndDepTeamEntities.add(userAndDepTeamEntity);
        }

        return userAndDepTeamEntities;
    }

    public abstract UserAndDepTeamEntity transferFormDataToTeam(PaasFormDataEntity paasFormDataEntity);

    public PaasFormDataEntity createPaasFormDataEntityForUserTeam(UserAndDepTeamEntity userAndDepTeamEntity) {
        PaasFormDataEntity paasFormDataEntity = new PaasFormDataEntity();
        paasFormDataEntity.setAddTime(userAndDepTeamEntity.getAddTime());
        paasFormDataEntity.setUpdateTime(userAndDepTeamEntity.getUpdateTime());
        paasFormDataEntity.setCorpid(userAndDepTeamEntity.getCorpid());
        paasFormDataEntity.setDel(userAndDepTeamEntity.getDel());
        paasFormDataEntity.setId(userAndDepTeamEntity.getId());
        return paasFormDataEntity;
    }

}
